package com.leo.mapper;

import com.leo.model.UserInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @ClassName: UserInfoMapper
 * @Description: ${description}
 * @Author: leo825
 * @Date: 2020-05-18 23:16
 * @Version: 1.0
 */
public interface UserInfoMapper {
    /**
     * 增加用户信息
     *
     * @param userInfo
     */
    @Insert("INSERT INTO USER_INFO(NAME,GENDER,AGE,REMARKS) VALUES(#{name},#{gender},#{age},#{remarks})")
    void insertUserInfo(UserInfo userInfo);

    /**
     * 删除用户信息
     *
     * @param id
     */
    @Delete("DELETE FROM USER_INFO WHERE ID=#{ID}")
    void deleteUserInfo(Integer id);

    /**
     * 修改用户信息
     *
     * @param newUserInfo
     */
    @Update("UPDATE USER_INFO SET NAME = #{name},GENDER = #{gender},AGE = #{age},REMARKS = #{remarks}")
    void updateUserInfo(UserInfo newUserInfo);

    /**
     * 查询用户信息
     *
     * @return
     */
    @Select("SELECT ID id, NAME name, GENDER gender,AGE age,REMARKS remarks FROM USER_INFO WHERE 1=1")
    List<UserInfo> getUserInfoList();
}
